package cn.sf.sufinguserconsumer.service;

import cn.sf.pojo.User;
import cn.sf.sufinguserconsumer.fallback.UserServiceFallback;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author sric
 */
@FeignClient(name = "sufing-user-provider", fallback = UserServiceFallback.class)
public interface UserService {

    @RequestMapping("/queryInformation")
    User queryInformation(@RequestParam("id") Long id);

    @RequestMapping("/updateUserById")
    String updateUserById(User user);


    /**
     * 从服务注册中心去找这个从redis中查询当前登录的个人信息
     * @param id
     * @return
     */
    @RequestMapping("/getRedisUserById")
    User getRedisUserById(@RequestParam("id") Long id);

    @RequestMapping("/uploadHead")
    String uploadHead(@RequestParam("userHead") String userHead, @RequestParam("userId") Long userId);

    //登录
    @RequestMapping("/queryUser")
    public User queryUser(@RequestParam("userCode") String userCode, @RequestParam("userPassword") String userPassword);

    //注册
    @RequestMapping("/userAdd")
    public int userAdd(@RequestBody User user);

    //查询是否关注
    @RequestMapping("/queryIsOrNotAttention")
    public boolean queryIsOrNotAttention(@RequestParam("userId1") long userId1,
                                         @RequestParam("userId2") long userId2);

    /**
     * //关注用户
     * //取消关注该用户
     *
     * @param userId1
     * @param userId2
     * @return
     * @throws Exception
     */
    @RequestMapping("/userAttention")
    public boolean userAttention(@RequestParam("userId1") long userId1,
                                 @RequestParam("userId2") long userId2) throws Exception;


}
